package src;

import javax.swing.*;
import java.awt.*;

public class BalanceQueryDialog extends JDialog {
    private String cardNumber;
    private JLabel balanceLabel;

    public BalanceQueryDialog(Frame owner, String cardNumber) {
        super(owner, "余额查询", true);
        this.cardNumber = cardNumber;
        setSize(300, 200);
        setLocationRelativeTo(owner);

        JPanel panel = new JPanel(new GridLayout(3, 1, 10, 10));
        panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        // 显示卡号
        panel.add(new JLabel("卡号: " + cardNumber, SwingConstants.CENTER));

        // 显示余额
        balanceLabel = new JLabel("余额: 加载中...", SwingConstants.CENTER);
        balanceLabel.setFont(new Font("微软雅黑", Font.BOLD, 16));
        panel.add(balanceLabel);

        // 添加关闭按钮
        JButton closeButton = new JButton("关闭");
        closeButton.addActionListener(e -> dispose());
        panel.add(closeButton);

        add(panel);

        // 加载余额数据
        loadBalance();
    }

    private void loadBalance() {
        // TODO: 实现从数据库加载余额数据
        // 这里只是示例，实际应该从数据库查询
        balanceLabel.setText("余额: ¥1,000.00");
    }
} 